home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap17 / FontRot / FontRot.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.1 KB  |  37 lines

  1. /*----------------------------------------
  2.    FONTROT.C -- Rotated Fonts
  3.                 (c) Charles Petzold, 1998
  4.   ----------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "..\\eztest\\ezfont.h"
  8.  
  9. TCHAR szAppName [] = TEXT ("FontRot") ;
  10. TCHAR szTitle   [] = TEXT ("FontRot: Rotated Fonts") ;
  11.  
  12. void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
  13. {
  14.      static TCHAR szString [] = TEXT ("   Rotation") ;
  15.      HFONT        hFont ;
  16.      int          i ;
  17.      LOGFONT      lf ;
  18.  
  19.      hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 540, 0, 0, TRUE) ;
  20.      GetObject (hFont, sizeof (LOGFONT), &lf) ;
  21.      DeleteObject (hFont) ;
  22.  
  23.      SetBkMode (hdc, TRANSPARENT) ;
  24.      SetTextAlign (hdc, TA_BASELINE) ;
  25.      SetViewportOrgEx (hdc, cxArea / 2, cyArea / 2, NULL) ;
  26.  
  27.      for (i = 0 ; i < 12 ; i ++)
  28.      {
  29.           lf.lfEscapement = lf.lfOrientation = i * 300 ;
  30.           SelectObject (hdc, CreateFontIndirect (&lf)) ;
  31.  
  32.           TextOut (hdc, 0, 0, szString, lstrlen (szString)) ;
  33.  
  34.           DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT))) ;
  35.      }
  36. }
  37.